.ai-chat-container {
  display: flex;
  flex-direction: column;
  height: 80vh;
  max-width: 900px;
  width: 85%;
  margin: 40px auto;
  background-color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  transition: all 0.3s ease;

  .chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background-image: linear-gradient(to bottom, rgba(240, 249, 255, 0.2), rgba(240, 249, 255, 0.6));

    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 3px;
    }

    &::-webkit-scrollbar-thumb {
      background: #c1c1c1;
      border-radius: 3px;
    }

    .message-item {
      display: flex;
      margin-bottom: 24px;
      animation: fadeIn 0.3s ease;

      .message-avatar {
        width: 44px;
        height: 44px;
        margin-right: 14px;
        flex-shrink: 0;
        position: relative; // 添加相对定位
        border-radius: 50%;
        background-color: #f0f0f0; // 添加背景色
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden; // 确保内容不溢出

        img {
          width: 100%;
          height: 100%;
          border-radius: 50%;
          object-fit: cover;
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
          border: 2px solid #ffffff;
          transition: all 0.3s ease; // 添加过渡效果
        }

        // 用户头像特殊效果
        &.user-avatar::after {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          border-radius: 50%;
          box-shadow: inset 0 0 0 1px rgba(24, 144, 255, 0.3);
          z-index: 1;
        }

        // AI头像特殊效果
        &.ai-avatar::after {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          border-radius: 50%;
          box-shadow: inset 0 0 0 1px rgba(82, 196, 26, 0.3);
          z-index: 1;
        }
      }

      .message-content {
        max-width: 60%;

        .message-role {
          font-weight: bold;
          margin-bottom: 6px;
          font-size: 14px;
        }

        .message-text {
          padding: 14px 18px;
          border-radius: 18px;
          line-height: 1.6;
          word-break: break-word;
          box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
          font-size: 15px;
        }
      }

      &.user-message {
        justify-content: flex-end;

        .message-avatar {
          margin-right: 0;
          margin-left: 14px;
        }

        .message-content {
          max-width: 66.7%;

          .message-role {
            color: #1890ff;
            text-align: right;
          }

          .message-text {
            background-color: #e6f7ff;
            border: none;
            background-image: linear-gradient(135deg, #e6f7ff, #bae7ff);
            color: #0050b3;
            border-top-right-radius: 4px;
          }
        }
      }

      &.ai-message {
        justify-content: flex-start;

        .message-content {
          max-width: calc(100% - 58px);

          .message-role {
            color: #52c41a;
          }

          .message-text {
            background-color: #f6ffed;
            border: none;
            background-image: linear-gradient(135deg, #f6ffed, #d9f7be);
            color: #135200;
            border-top-left-radius: 4px;
          }
        }
      }

      &.thinking-animation {
        .thinking-dots {
          display: flex;
          align-items: center;
          justify-content: center;
          min-height: 24px;
          min-width: 60px;

          span {
            display: inline-block;
            width: 8px;
            height: 8px;
            margin: 0 4px;
            background-color: #52c41a;
            border-radius: 50%;
            opacity: 0.6;
            animation: thinking 1.4s infinite ease-in-out both;

            &:nth-child(1) {
              animation-delay: -0.32s;
            }

            &:nth-child(2) {
              animation-delay: -0.16s;
            }

            &:nth-child(3) {
              animation-delay: 0s;
            }
          }
        }
      }
    }
  }

  .chat-input-area {
    padding: 18px 20px;
    border-top: 1px solid #f0f0f0; // 更淡的分隔线
    background-color: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03); // 添加上阴影

    .input-container {
      position: relative;

      .chat-textarea {
        width: 96%;
        min-height: 80px;
        padding: 14px;
        border: 1px solid #e8e8e8;
        border-radius: 8px; // 增加圆角
        resize: none;
        font-size: 15px;
        line-height: 1.6;
        transition: all 0.3s ease;

        &:focus {
          outline: none;
          border-color: #40a9ff;
          box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.15);
        }
      }

      .input-actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 10px;

        .action-button {
          width: 46px;
          height: 46px;
          border-radius: 50%;
          border: none;
          display: flex;
          align-items: center;
          justify-content: center;
          cursor: pointer;
          transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
          background-color: #8c8c8c;
          color: white;
          position: relative;
          overflow: hidden;

          i {
            font-size: 20px;
            transition: all 0.3s ease;
          }

          &:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);

            &::before {
              transform: translate(-50%, -50%) scale(1);
              opacity: 0;
            }
          }

          &::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            transform: translate(-50%, -50%) scale(0);
            opacity: 1;
            transition: transform 0.6s ease, opacity 0.6s ease;
          }

          &:active {
            transform: translateY(0);
          }

          &:disabled {
            background-color: #d9d9d9;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
          }

          .action-icon {
            width: 24px;
            height: 24px;
            transition: all 0.3s ease;
          }

          &.thinking {
            background-color: #8c8c8c;

            &:hover {
              background-color: #595959;
            }

            .action-icon {
              transform: scale(1.1);
            }
          }
        }
      }
    }
  }
}

// 添加思考动画关键帧
@keyframes thinking {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

// 添加动画
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-text {
  // ... 现有样式 ...

  .markdown-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 12px 0;
    background-color: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);

    th,
    td {
      padding: 12px 16px;
      text-align: left;
      border: 1px solid #e8e8e8;
      transition: all 0.3s ease;
    }

    th {
      background: linear-gradient(to bottom, #f8fafd, #f0f5ff);
      font-weight: 600;
      color: #1f1f1f;
      border-bottom: 2px solid #1890ff;
      text-shadow: 0 1px 0 #fff;
      position: relative;

      &:not(:last-child)::after {
        content: '';
        position: absolute;
        right: 0;
        top: 20%;
        height: 60%;
        width: 1px;
        background-color: rgba(24, 144, 255, 0.2);
      }
    }

    td {
      color: #595959;
      background-color: #ffffff;
      border: 1px solid #e8e8e8;
    }

    tr {
      &:nth-child(even) td {
        background-color: #fafafa;
      }

      &:hover td {
        background-color: #f0f7ff;
      }
    }
  }
}

.message-role {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;

  .copy-button {
    opacity: 0;
    padding: 6px 8px;
    border: none;
    background: rgba(0, 0, 0, 0.04);
    cursor: pointer;
    color: #8c8c8c;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;

    &:hover {
      background-color: rgba(24, 144, 255, 0.1);
      color: #1890ff;
      transform: translateY(-1px);
    }

    &:active {
      transform: translateY(0);
    }

    i {
      font-size: 14px;
    }

    &::after {
      content: '复制';
      font-size: 12px;
    }
  }
}

// 鼠标悬停在消息上时显示复制按钮
.message-item:hover {
  .copy-button {
    opacity: 1;
  }
}

.thinking-message {
  background: linear-gradient(135deg, #f0f5ff, #e6f7ff) !important;
  border-left: 3px solid #1890ff !important;
  font-style: italic;
  color: #666 !important;
  animation: thinking-pulse 2s infinite ease-in-out;
  position: relative;
  padding: 16px 20px !important;
  margin-top: 24px !important;
}

.thinking-message::before {
  content: '思考过程';
  position: absolute;
  top: -12px;
  left: 16px;
  font-size: 12px;
  color: #1890ff;
  background: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid #1890ff;
  font-style: normal;
}

@keyframes thinking-pulse {
  0% {
    opacity: 0.8;
    border-left-color: #1890ff;
  }

  50% {
    opacity: 1;
    border-left-color: #40a9ff;
  }

  100% {
    opacity: 0.8;
    border-left-color: #1890ff;
  }
}

/* 样式优化 Markdown 表格 */
.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid #ddd;
  padding: 8px;
}

.markdown-content th {
  background-color: #f4f4f4;
  text-align: left;
}

